package org.danan.spark2hudi.utils;

import org.apache.spark.sql.catalog.Database;
import org.danan.spark2hudi.bean.DatabaseConfig;

import java.util.ResourceBundle;

/**
 * @author NanHuang
 * @Date 2023/1/24
 */
public class ConfigUtil {

    private static final ResourceBundle config = ResourceBundle.getBundle("config");

    public static String getProperty(String keyName){
        return config.getString(keyName);
    }

    public static DatabaseConfig getSxycHisConfig(){
        return DatabaseConfig.builder()
                .url(getProperty("sxyc.his.url"))
                .user(getProperty("sxyc.his.user"))
                .password(getProperty("sxyc.his.password"))
                .type(getProperty("sxyc.his.type"))
                .build();
    }

    public static DatabaseConfig getSxycEmrConfig(){
        return DatabaseConfig.builder()
                .url(getProperty("sxyc.emr.url"))
                .user(getProperty("sxyc.emr.user"))
                .password(getProperty("sxyc.emr.password"))
                .type(getProperty("sxyc.emr.type"))
                .build();
    }

    public static DatabaseConfig getScyyHisEmrConfig(){
        return DatabaseConfig.builder()
                .url(getProperty("scyy.his/emr.url"))
                .user(getProperty("scyy.his/emr.user"))
                .password(getProperty("scyy.his/emr.password"))
                .type(getProperty("scyy.his/emr.type"))
                .build();
    }

    public static DatabaseConfig getScyyPacsConfig(){
        return DatabaseConfig.builder()
                .url(getProperty("scyy.pacs.url"))
                .user(getProperty("scyy.pacs.user"))
                .password(getProperty("scyy.pacs.password"))
                .type(getProperty("scyy.pacs.type"))
                .build();
    }

    public static DatabaseConfig getSzgcHisEmrConfig(){
        return DatabaseConfig.builder()
                .url(getProperty("szgc.his/emr.url"))
                .user(getProperty("szgc.his/emr.user"))
                .password(getProperty("szgc.his/emr.password"))
                .type(getProperty("szgc.his/emr.type"))
                .build();
    }

    public static DatabaseConfig getSzgcPacsConfig(){
        return DatabaseConfig.builder()
                .url(getProperty("szgc.pacs.url"))
                .user(getProperty("szgc.pacs.user"))
                .password(getProperty("szgc.pacs.password"))
                .type(getProperty("szgc.pacs.type"))
                .build();
    }

    public static DatabaseConfig getTestConfig(){
        return DatabaseConfig.builder()
                .url(getProperty("test.url"))
                .user(getProperty("test.user"))
                .password(getProperty("test.password"))
                .type(getProperty("test.type"))
                .build();
    }

}
